-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pull Request by Zilin Huang regarding Issue #216 #226
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @huangz73 !
I left a couple of comments that need to be addressed. Also, you will need to re-document the site with devtools::document()
.
R/scale_ggsurvfit.R
Outdated
@@ -34,8 +34,20 @@ | |||
#' # specify additional scales | |||
#' ggsurvfit + | |||
#' scale_ggsurvfit(x_scales = list(breaks = seq(0, 8, by = 2))) | |||
#' | |||
#' # Specical case: in the risk table, large numbers (with more than 4 digits) may not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of putting this text as a comment in the examples section, let's add it to a new section the help file using the #' @details
tag.
R/scale_ggsurvfit.R
Outdated
#' # Specical case: in the risk table, large numbers (with more than 4 digits) may not | ||
#' # be shown completely, with some digits truncated outside the plot region. | ||
#' # To remedy this, consider the following example code for a simulated large-size survival dataset: | ||
#' # Here, adjust the size in `add_risktable(size = 2.5)` (as an example) can decrease the font size of the risk table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason people see this issue is because the default padding when using scale_ggsurvit()
is too restrictive, so the best "fix" is going to live here in this function rather than reducing the font size of the risk table.
The proposed fix is going to be a change to the expand scale argument in this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @ddsjoberg a lot for your suggestion, I've already addressed this issue and inside the new commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more small change and we can merge, thank you
#' @inherit ggsurvfit seealso | ||
scale_ggsurvfit <- function(x_scales = list(), y_scales = list()){ | ||
scale_ggsurvfit <- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put this back on one line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have already done this. It'll be ready to merge.
#' Specical case: in the risk table, large numbers (with more than 4 digits) may not | ||
#' be shown completely, with some digits truncated outside the plot region. | ||
#' To remedy this, consider the following example code for a simulated large-size survival dataset: | ||
#' Here, adjust the expand size in `scale_ggsurvfit(x_scales = list(expand = c(0.05, 0)))` (for example) | ||
#' can modify the position of numbers in the risk table | ||
#' and make them all fit in the plot region. The scale of the `expand` argument differs by cases. | ||
#' | ||
#' df_colon_large <- df_colon[sample(1:nrow(df_colon), size = 15*nrow(df_colon), replace = TRUE), ] | ||
#' ggsurvfit <- | ||
#' survfit2(Surv(time, status) ~ surg, data = df_colon_large) %>% | ||
#' ggsurvfit() + add_risktable() + | ||
#' scale_ggsurvfit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thank you!
upon looking at it, perhaps we don't need the full example, and just keep this part: scale_ggsurvfit(x_scales = list(expand = c(0.05, 0)))
"Argument {.arg x} does not support {.cls survfit.coxphms} object. | ||
Please fit a multi-state model with another project, such as {.fn coxph}." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thank you for adding. Let's keep the message simple with "Argument {.arg x} does not support {.cls survfit.coxphms} object."
.
Can you also add a unit test to test appropriate error messaging with expect_error()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ddsjoberg, I'll work with the unit test later (on Issue #222 PR)
|
Updated the documentation for
scale_ggsurvfit.R
to address the issue of truncated number in risk table, along with code example to remedy this issue.